﻿
using System;
using System.Collections.Generic;
using System.Linq;
using Tau.DataAccess;

namespace Tau.Service.Adapters
{
    internal class Image : IAdapter<Model.Image, tblImage>
    {
        public Model.Image GetModelObject(tblImage dbObject)
        {
            var model = new Model.Image
            {
                Category = dbObject.imageCategory,
                ImageId = dbObject.imageID,
                LargeImage = dbObject.largeImage,
                Size = dbObject.size,
                ThumbnailImage = dbObject.thumbnailImage,
                FileName = dbObject.fileName,
                CreatedDate = dbObject.createdDate
            };
            return model;
        }

        public tblImage GetDbObject(Model.Image model)
        {
            var dbObject = new tblImage
            {
                imageCategory = model.Category,
                imageID = model.ImageId,
                largeImage = model.LargeImage,
                size = model.Size,
                thumbnailImage = model.ThumbnailImage,
                fileName = model.FileName,
                createdDate = model.CreatedDate
            };
            return dbObject;
        }

        public List<Model.Image> GetModelList(List<tblImage> dbObjectList)
        {
            var imageList = dbObjectList.Select(dbImage => GetModelObject(dbImage)).ToList();
            return imageList;
        }
    }
}
